package me.zk.entity;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author: zhang kai
 * @Date: 2022/07/26
 * @Description:
 */
public class OrderEntity implements InitializingBean, DisposableBean, BeanNameAware, BeanPostProcessor {

    public void xmlInitMethod() {
        System.out.println("xmlInitMethod");
    }

    public void xmlDestroyMethod() {
        System.out.println("xmlDestroyMethod");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("@PostConstruct");
    }
    @PreDestroy
    public void preDestroy() {
        System.out.println("@PreDestroy");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean destroy");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean afterPropertiesSet");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("BeanNameAware setBeanName");
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
